Add data to Links

Hi All,

I need a way of adding an integer attribute, and additional data to a link between a requirement and test case. The user needs to add a number to each outgoing link from Requirement to test case, so one can determine the order of which the test cases should be executed. So, i need someway to add additional attributes (a number and a string) to an outgoing link. How can this be solved?

Im under immense time pressure, i appreciate your help greatly!

Best regards


AppDevel - Fri May 01 09:59:20 EDT 2015

Re: Add data to Links
woodpryan - Fri May 01 11:10:30 EDT 2015

Well, Links are actually Objects just like the Objects in Formal Modules are. They are Objects inside the Link Modules. The following little script will add a string Attribute called "Object Description" to all the Link Modules in a Project. You can modify it as necessary to suit your needs, but I think this should give you at least an idea of what you're looking for.

int Main()
{
    Project proj       = current();
    Module  m          = null;
    string  s          = null;
    AttrDef ad         = null;
    Link    l          = null;
    bool    success    = false;
    int     numCreated = 0;
    Item    i;
    
    if(null != proj)
    {
        for i in proj do
        {
            if(type(i) == "Link")
            {
                s = fullName(i);
                m = edit(s, false);
                if(null != m)
                {
                    ad = create(object type "string" attribute "Object Description");
                    if(null != ad)
                    {
                        success = true;
                    }
                    save(m);
                    close(m);
                }
            }
            if(success)
            {
                numCreated++;
                success = false;
            }
        }
    }
    else
    {
        ack("Please select a Project");
        halt();
    }
    
    ack("Added the Object Description Attribute to " numCreated " Link Modules.");
    
    return 0;
}
 
Main();

 

Re: Add data to Links
AppDevel - Fri May 01 12:06:19 EDT 2015

woodpryan - Fri May 01 11:10:30 EDT 2015

Well, Links are actually Objects just like the Objects in Formal Modules are. They are Objects inside the Link Modules. The following little script will add a string Attribute called "Object Description" to all the Link Modules in a Project. You can modify it as necessary to suit your needs, but I think this should give you at least an idea of what you're looking for.

int Main()
{
    Project proj       = current();
    Module  m          = null;
    string  s          = null;
    AttrDef ad         = null;
    Link    l          = null;
    bool    success    = false;
    int     numCreated = 0;
    Item    i;
    
    if(null != proj)
    {
        for i in proj do
        {
            if(type(i) == "Link")
            {
                s = fullName(i);
                m = edit(s, false);
                if(null != m)
                {
                    ad = create(object type "string" attribute "Object Description");
                    if(null != ad)
                    {
                        success = true;
                    }
                    save(m);
                    close(m);
                }
            }
            if(success)
            {
                numCreated++;
                success = false;
            }
        }
    }
    else
    {
        ack("Please select a Project");
        halt();
    }
    
    ack("Added the Object Description Attribute to " numCreated " Link Modules.");
    
    return 0;
}
 
Main();

 

Thank you for your response woodpryan!

Is it possible to add attributes such as the one you mentioned "Object Description" to both Internal and External outgoing links? If so, can i use the code you used above for creating attributes in external links? 

So for creating an integer attribute, could something like this work:   ad = create(object type integer attribute 1);

Worth mentioning, Doors and DXL are new to me, so all information could be of assistance. Appreciate your help!

 

Best regards

Re: Add data to Links
woodpryan - Fri May 01 12:13:01 EDT 2015

AppDevel - Fri May 01 12:06:19 EDT 2015

Thank you for your response woodpryan!

Is it possible to add attributes such as the one you mentioned "Object Description" to both Internal and External outgoing links? If so, can i use the code you used above for creating attributes in external links? 

So for creating an integer attribute, could something like this work:   ad = create(object type integer attribute 1);

Worth mentioning, Doors and DXL are new to me, so all information could be of assistance. Appreciate your help!

 

Best regards

Actually, I don't know the answer to that question, my friend. I've never tried it before. Give it a shot, and find out. Take a look at the DXL reference manual and see if you can find anything about it.